/*用于主界面的交易统计以及下面快捷菜单的js*/
/*导行滚动，上下，今日，本月*/
(function(){
	var nav_today=$("#nav_today"),
		nav_today_up=$("#nav_today_up"),
		nav_today_down=$("#nav_today_down"),
		ul=nav_today.find("ul");
		ul_h=nav_today.height();
	nav_today.append(ul.clone());
	var n=0;
	var ul_size=ul.size();
	function start()
	{
	    scrollUp();
	    if(n==ul_size)
	    {
		    nav_today.scrollTop(0);
		    n=0;
	    }
	}
	
	var timer=window.setInterval(function(){
		start();
	},2000);
	
	function stop()
	{
	    clearInterval(timer);
	}
	
	function restart()
	{
	    timer=window.setInterval(function(){
		    start();
	    },2000);
	}
	
	//向上卷动一个ul
	function scrollUp(){
	    if(nav_today.is(":animated")){return false;}
		nav_today.animate({scrollTop:nav_today.scrollTop()+ul_h},"normal",function(){
		        n++;
		        if(n==ul_size){
		            nav_today.scrollTop(0);
		            n=0;
		        }
		    }
	    );
	}
	//向下卷动一个ul
	function scrollDown(){
	    if(nav_today.is(":animated")){return false;}
		nav_today.animate({scrollTop:nav_today.scrollTop()-ul_h},"normal",function(){
		        n--;
		        if(n==0){
		            n=ul_size;
		            nav_today.scrollTop(ul_h*ul_size);
		        };
		    }
		);
	}
	nav_today.mouseover(function(){
		stop();
	}).mouseout(function(){
		restart();
	})
	nav_today_up.click(function(){
	    if(n==0){
            n=ul_size;
            nav_today.scrollTop(ul_h*ul_size);
	    }
		scrollDown();
		return false;
	});
	nav_today_down.click(function(){
	    if(n==ul_size)
	    {
	        n=0;
	        nav_today.scrollTop(0);
	    }
		scrollUp();
		return false;
	});
})();